<template>
  <div class="linel">
      <div id="linel" style="width: 90%;height:400px;"></div>
  </div>  
</template>

<script>
    // 引入 echarts 主模块。
    import * as echarts from 'echarts/lib/echarts';
    // 引入折线图。
    import 'echarts/lib/chart/line';
    import 'echarts/lib/chart/bar';
    // 引入提示框组件、标题组件、工具箱组件。
    import 'echarts/lib/component/tooltip';
    import 'echarts/lib/component/title';
    import 'echarts/lib/component/toolbox';
     import 'echarts/lib/component/legend';
    import 'echarts/lib/component/markPoint';
    
    export default {
        name:"Echarts",
        mounted(){
          this.myChart=echarts.init(document.getElementById("linel"))
          this.initData();
        },
        methods:{
           initData(){
                const option = {
                title: {
                    text: '图表'
                },
                tooltip: {},
                legend: {
                    data:['销量']
                },
                xAxis: {
                    data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
                },
                yAxis: {},
                series: [{
                    name: '销量',
                    type: 'bar',
                    data: [5, 20, 36, 10, 10, 20]
                }]
        };
            // 使用刚指定的配置项和数据显示图表。
            this.myChart.setOption(option);
           } 
        }
    }
</script>

<style lang="scss" scoped>

</style>